export default {
  state: {
    isCollapse: false,
    currenMenu: null,
    tableList: [{
      path: '/home',
      name: 'home',
      label: '首页',
      icon: 'home'
    }]
  },
  mutations: {
    collapseMenu(state) {
      state.isCollapse = !state.isCollapse
    },
    selectMenu(state, val) {
      // val.name === 'home' ? (state.currenMenu = null) : state.currenMenu = val

      if (val.name == 'home') {
        state.currenMenu = null;
      } else {
        state.currenMenu = val;
        //新增tablesList
        let result = state.tableList.findIndex(item => item.name == val.name)
        result === -1 ? state.tableList.push(val) : '';
      }
    },
    closeTag(state, val) {
      let result = state.tableList.findIndex(item => item.name == val.name)
      state.tableList.splice(result, 1)
    }
  }
}
